<?php
if (isset($_GET["editar"])) {
			$id = $_GET["editar"];
			switch ($_GET["subsec"]) {
				case 'proveedores' :
					$c = "select * from prv_proveedor where prv_rut=$id";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<div id='login-box2' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center><span><h2>Editar Proveedor</h2></span></center>
<fieldset class='textbox'>
<center>
<table>
<tr>
<td><span>Rut</span></td>
<td><input type='rut' name='rut' id='rut'  readonly='readonly' required='required' value='$row[0]'><input type='dv' name='dv' id='dv' required='required' value='$row[1]'> </td>
</tr>
<tr>
<td><span>Nombre</span></td>
<td><input type='text' name='nombre' id='nombre' required='required' value='$row[3]'></td>
</tr>
<tr>
<td><span>Comuna</span></td>
<td><input type='text' name='comuna' id='comuna' required='required' value='$row[5]'></td>
</tr>
<tr>
<td><span>Ciudad</span></td>
<td><input type='text' name='ciudad' id='ciudad' required='required' value='$row[6]'></td>
</tr>
<tr>
<td><span>Telefono</span></td>
<td><input type='number' name='telefono' id='telefono' required='required' value='$row[7]'></td>
</tr>
<tr>
<td><span>Email</span></td>
<td><input type='email' name='email' id='email' required='required' value='$row[8]'></td>
</tr>
<tr>
<td><span>Fax</span></td>
<td><input type='number' name='fax' id='fax' required='required'value='$row[9]'></td>
</tr>
<tr>
<td><span>Giro</span></td>
<td><input type='text' name='giro' id='giro' value='$row[10]'></td>
</tr>
<tr>
<td><span>Direccion</span></td>
<td><input type='text' name='direccion' id='direccion' value='$row[4]'></td>
</tr>
</table>

</center>
<button type='submit' class='submit button' id='do' name='do' value='Editar Proveedor'>Grabar</button>
</fieldset>
</form>
</div>

</div>
</div>
";
					}//while
					break;
				case "categorias" :
					$c = "select * from cat_categoria where cat_codigo=$id";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<!-- pop up -->
<div id='login-box-cat-edit' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center>
<span><h2>Editar Categoria</h2></span>
</center>
<fieldset class='textbox'>
<center>
<table>
<tr>
<td><span>Codigo</span></td>
<td>
<input type='text' name='codigo' id='codigo' readonly='readonly' required='required' value='$row[0]'>
</td>
</tr>
<tr>
<td><span>Descripcion</span></td>
<td>
<input type='text' name='descripcion' id='descripcion' required='required' value='$row[1]'>
</td>
</tr>
</table>
</center>
<button type='submit' class='submit button' id='do' name='do' value='Editar Categoria'>
Grabar</button>
</fieldset>
</form>
</div>

</div>
</div>

<!-- end pop up -->
";
					}//while cate
					break;
case "subcategorias" :
					$c = "SELECT * FROM sbc_subcategoria where sbc_codigo=$id";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<!-- pop up -->
<div id='login-box-subcat-edit' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center>
<span><h2>Editar SubCategoria</h2></span>
</center>
<fieldset class='textbox'>
<center>
<table>
<tr>
<td><span>Codigo</span></td>
<td>
<input type='text' name='codigo' id='codigo' readonly='readonly' required='required' value='$row[1]'>
</td>
</tr>
<tr>
<td><span>Categoria</span></td>
<td>
<select name='id_categoria'>
<optgroup label='Categorias Disponibles'>";
$qry=mysql_query("select cat_codigo,cat_descripcion from cat_categoria");
while($row2=mysql_fetch_row($qry)){
echo "<option value='$row2[0]'"; if($row[0]==$row2[0]){echo "selected";}echo" >$row2[1]";
}
echo"
</select>
</td>
</tr>
<tr>
<td><span>Descripcion</span></td>
<td>
<input type='text' name='descripcion' id='descripcion' required='required' value='$row[2]'>
</td>
</tr>
</table>
</center>
<button type='submit' class='submit button' id='do' name='do' value='Editar Subcategoria'>
Grabar</button>
</fieldset>
</form>
</div>

</div>
</div>

<!-- end pop up -->
";
					}//while cate
					break;
case "sucursales" :
					$c = "select * from suc_sucursal where suc_codigo=$id";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<!-- pop up -->
<div id='login-box-suc-edit' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center>
<span><h2>Editar Sucursal</h2></span>
</center>
<fieldset class='textbox'>
<center>
<table>
<tr>
<td><span>Codigo</span></td>
<td>
<input type='text' name='codigo' id='codigo' readonly='readonly' required='required' value='$row[0]'>
</td>
</tr>
<tr>
<td><span>Direccion</span></td>
<td>
<input type='text' name='direccion' id='direccion' required='required' value='$row[1]'>
</td>
</tr>
<tr>
<td><span>Telefono</span></td>
<td>
<input type='number' name='telefono' id='telefono' required='required' value='$row[2]'>
</td>
</tr>
<tr>
<td><span>Rut</span></td>
<td>
<input type='text' name='rut' id='rut' required='required' value='$row[3]'>
</td>
</tr>
<tr>
<td><span>Email</span></td>
<td>
<input type='text' name='email' id='email' required='required' value='$row[4]'>
</td>
</tr>
</table>
</center>
<buton type='submit' class='submit button' id='do' name='do' value='Editar Sucursal'>
Grabar</button>
</fieldset>
</form>
</div>

</div>
</div>

<!-- end pop up -->
";
					}//while cate
					break;
	
case "cajas" :
					$c = "select * from cja_cajas where cja_codigo=$id";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<!-- pop up -->
<div id='login-box-cja-edit' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center>
<span><h2>Editar Caja</h2></span>
</center>
<fieldset class='textbox'>
<center>
<table>
<tr>
<td><span>Codigo</span></td>
<td>
<input type='text' name='codigo' id='codigo' readonly='readonly' required='required' value='$row[0]'>
</td>
</tr>
<tr>
<td><span>Descripcion</span></td>
<td>
<input type='text' name='descripcion' id='descripcion' required='required' value='$row[1]'>
</td>
</tr>
<tr>
<td><span>Folio Boleta</span></td>
<td>
<input type='text' name='folio' id='folio' required='required' value='$row[2]'>
</td>
</tr>
</table>
</center>
<button type='submit' class='submit button' id='do' name='do' value='Editar Caja'>
Grabar</button>
</fieldset>
</form>
</div>

</div>
</div>

<!-- end pop up -->
";
					}//while cate
					break;

case "cajeros" :
					$c = "select * from caj_cajeros where caj_codigo=$id";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<!-- pop up -->
<div id='login-box-caj-edit' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center>
<span><h2>Editar Cajero</h2></span>
</center>
<fieldset class='textbox'>
<center>
<table>
<tr>
<td><span>Codigo</span></td>
<td>
<input type='text' name='codigo' id='codigo' readonly='readonly' required='required' value='$row[0]'>
</td>
</tr>
<tr>
<td><span>Descripcion</span></td>
<td>
<input type='text' name='descripcion' id='descripcion' required='required' value='$row[1]'>
</td>
</tr>
<tr>
<td><span>Nombre</span></td>
<td>
<input type='text' name='nombre' id='nombre' required='required' value='$row[2]'>
</td>
</tr>
<tr>
<td><span>Email</span></td>
<td>
<input type='email' name='email' id='email' required='required' value='$row[3]'>
</td>
</tr>
<tr>
<td><span>Direccion</span></td>
<td>
<input type='text' name='direccion' id='direccion' required='required' value='$row[4]'>
</td>
</tr>
<tr>
<td><span>Telefono</span></td>
<td>
<input type='number' name='telefono' id='telefono' required='required' value='$row[5]'>
</td>
</tr>
<tr>
<td><span>Celular</span></td>
<td>
<input type='number' name='celular' id='celular' required='required' value='$row[6]'>
</td>
</tr>
</table>
</center>
<button type='submit' class='submit button' id='do' name='do' value='Editar Cajero'>
Grabar</button>
</fieldset>
</form>
</div>

</div>
</div>

<!-- end pop up -->
";
					}//while cate
					break;
case "envases" :
					$c = "select * from env_envase where env_codigo='$id'";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<!-- pop up -->
<div id='login-box-env-edit' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center>
<span><h2>Editar Envase</h2></span>
</center>
<fieldset class='textbox'>
<center>
<table>
<tr>
<td><span>Codigo</span></td>
<td>
<input type='text' name='codigo' id='codigo' readonly='readonly' required='required' value='$row[0]'>
</td>
</tr>
<tr>
<td><span>Descripcion</span></td>
<td>
<input type='text' name='descripcion' id='descripcion' required='required' value='$row[1]'>
</td>
</tr>
<tr>
<td><span>Sigla</span></td>
<td>
<input type='text' name='sigla' id='sigla' required='required' value='$row[2]'>
</td>
</tr>
</table>
</center>
<button type='submit' class='submit button' id='do' name='do' value='Editar Envase'>
Grabar</button>
</fieldset>
</form>
</div>

</div>
</div>

<!-- end pop up -->
";
					}//while cate
					break;
case "bodegas" :
					$c = "select * from bod_bodega where bod_bodega=$id";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<!-- pop up -->
<div id='login-box-bod-edit' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center>
<span><h2>Editar Bodega</h2></span>
</center>
<fieldset class='textbox'>
<center>
<table>
<tr>
<td><span>Codigo</span></td>
<td>
<input type='text' name='codigo' id='codigo' readonly='readonly' required='required' value='$row[0]'>
</td>
</tr>
<tr>
<td><span>Descripcion</span></td>
<td>
<input type='text' name='descripcion' id='descripcion' required='required' value='$row[1]'>
</td>
</tr>

<tr>
<td><span>Jefe</span></td>
<td>
<input type='text' name='jefe' required='required' value='$row[2]'>
</td>
</tr>
<tr>
<td><span>Email</span></td>
<td>
<input type='text' name='email' id='email' required='required' value='$row[3]'>
</td>
</tr>
<tr>
<td><span>Direccion</span></td>
<td>
<input type='text' name='direccion' required='required' value='$row[4]'>
</td>
</tr>
<tr>
<td><span>Telefono</span></td>
<td>
<input type='number' name='telefono' id='telefono' required='required' value='$row[5]'>
</td>
</tr>
<tr>
<td><span>Celular</span></td>
<td>
<input type='text' name='celular' required='required' value='$row[6]'>
</td>
</tr>

</table>
</center>
<button type='submit' class='submit button' id='do' name='do' value='Editar Bodega'>
Grabar</button>
</fieldset>
</form>
</div>

</div>
</div>

<!-- end pop up -->
";
					}//while cate
					break;
case "formas_pagos" :
					$c = "select * from form_pagos where fp_codigo=$id";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<!-- pop up -->
<div id='login-box-fp-edit' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center>
<span><h2>Editar Foma de pago</h2></span>
</center>
<fieldset class='textbox'>
<center>
<table>


<tr>
<td><span>Codigo</span></td>
<td>
<input type='text' name='codigo' id='codigo' readonly='readonly' required='required' value='$row[0]'>
</td>
</tr>
<tr>
<tr>
<td><span>Glosa</span></td>
<td><input type='text' name='glosa' required='required' value='$row[1]'> </td>
</tr>
<tr>
<td><span>Afecto a IVA</span></td>
<td>
<select name='iva'>
<optgroup label='Elija Opcion'>
<option value='1'>Si</option>
<option value='0'"; if($row[2]==0){echo"selected";}echo">No</option>
</select>
</td>
</tr>
<tr>
<td><span>Imp. Boleta</span></td>
<td><select name='boleta'>
<optgroup label='Elija Opcion'>
<option value='1'>Si</option>
<option value='0' "; if($row[3]==0){echo"selected";}echo">No</option>
</select> </td>
</tr>
<tr>
<tr>
<td><span>Con costo</span></td>
<td><select name='costo'>
<optgroup label='Elija Opcion'>
<option value='1'>Si</option>
<option value='0'"; if($row[4]==0){echo"selected";}echo">No</option>
</select> </td>
</tr>
</table>
</center>
<button type='submit' class='submit button' id='do' name='do' value='Editar Forma'>
Grabar</button>
</fieldset>
</form>
</div>
</div>
</div>

<!-- end pop up -->
";
					}//while cate
					break;
case "clientes" :
					$c = "select * from cli_cliente where cli_rut=$id";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<!-- pop up -->
<div id='login-box-cli-edit' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center>
<span><h2>Editar Cliente</h2></span>
</center>
<fieldset class='textbox'>
<center>
<table>


<tr>
<tr>
<td><span>Rut</span></td>
<td><input type='rut' name='rut' id='rut' required='required' value='$row[0]'><input type='dv' id='dv' name='dv' value='$row[1]'></td>
</tr>
<tr>
<tr>
<td><span>Nombre</span></td>
<td><input type='text' name='nombre' required='required' value='$row[3]'> </td>
</tr>
<tr>
<tr>
<td><span>Direccion</span></td>
<td><input type='text' name='direccion' value='$row[4]'> </td>
</tr>
<tr>
<tr>
<td><span>Comuna</span></td>
<td><input type='text' name='comuna' value='$row[5]'> </td>
</tr>
<tr>
<tr>
<td><span>Ciudad</span></td>
<td><input type='text' name='ciudad' value='$row[6]'> </td>
</tr>
<tr>
<tr>
<td><span>Telefono</span></td>
<td><input type='text' name='telefono' value='$row[7]'> </td>
</tr>
<tr>
<tr>
<td><span>Email</span></td>
<td><input type='email' name='email' value='$row[8]'> </td>
</tr>
<tr>
<tr>
<td><span>Fax</span></td>
<td><input type='text' name='fax' value='$row[9]'> </td>
</tr>
<tr>
<tr>
<td><span>Giro</span></td>
<td><input type='text' name='giro' value='$row[10]'> </td>
</tr>

</table>
</center>
<button type='submit' class='submit button' id='do' name='do' value='Editar Cliente'>
Grabar</button>
</fieldset>
</form>
</div>
</div>
</div>

<!-- end pop up -->
";
					}//while cate
					break;

case "productos" :
					$c = "select * from pro_productos where pro_codigo='$id'";
					
					$qry = mysql_query($c);
					while ($rowe = mysql_fetch_row($qry)) {
						$tipo=$rowe[23];
						?>
<script src="js/calendario/src/js/jscal2.js"></script>
    <script src="js/calendario/src/js/lang/es.js"></script>
    <link rel="stylesheet" type="text/css" href="js/calendario/src/css/jscal2.css" />
	<link rel="stylesheet" type="text/css" href="js/calendario/src/css/border-radius.css" />	
    <link rel="stylesheet" type="text/css" href="js/calendario/src/css/steel/steel.css" />
    


 <!-- pop up -->
<div id='login-box-pro-edit' class='login-popup-asi'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>

            				            <div id="wrapper-asi">
                <div id="steps2">
                    <form id="formElem2" name="formElem2" action="includes/funciones.php" method="post">
                        <fieldset class="step">
                            <legend>Nuevo Producto</legend>
                            <p>
                                <label for="codigo_barra">Codigo Barra</label>
                                <input id="codigo_barra2" name="codigo_barra2" value="<?php echo $rowe[1] ?>"/>
                            </p>
                            <p><label>Codigo: <?php echo $rowe[0] ?> </label></p>
                      
                            <div id="destino2"></div>
                           <!-- <p>
                                <label for="codigo">Codigo</label>
                                <input id="codigo" name="codigo" />
                            </p> -->  
                            <p>
                                <label for="des_corta">Descripcion Corta</label>
                                <input id="des_corta" name="des_corta" value="<?php echo $rowe[2] ?>"/>
                            </p>  
                            <p>
                                <label for="des_larga">Descripcion Larga</label>
                                <input id="des_larga" name="des_larga" value="<?php echo $rowe[3] ?>"/>
                            </p> 
                            <p>
                                <label for="tipo">Tipo</label>
                                <select id="producto_tipo" name="producto_tipo">
                                	<option value="N" <?php  if($tipo=="N"){echo "selected='selected'";} ?>>No Pesado</option>
                                	<option value="P" <?php  if($tipo=="P"){echo "selected='selected'";} ?>>Pesado</option>
                                	
                                </select>
                            </p> 
                            <p>
                                <label for="categoria">Categoria</label>
<select name='categoria'>
<optgroup label='Categorias Disponibles'>";
	<?php
$qry=mysql_query("select cat_codigo,cat_descripcion from cat_categoria");
while($row=mysql_fetch_row($qry)){
echo "<option value='$row[0]'";if($row[0]==$rowe[5]){echo "selected='selected'";}echo">$row[1]</option>";
}
?>
</select>
                            </p> 
                            <p>
                                <label for="subcategoria">Subcategoria</label>
<select name='subcategoria'>
<optgroup label='SubCategorias Disponibles'>";
	<?php
$qry=mysql_query("select sbc_codigo,sbc_descripcion from sbc_subcategoria");
while($row=mysql_fetch_row($qry)){
echo "<option value='$row[0]'";if($row[0]==$rowe[6]){echo "selected='selected'";}echo">$row[1]</option>";
}
?>
</select>
                            </p>                                     

                        </fieldset>
                        <fieldset class="step">
                            <legend>Nuevo Producto</legend>
                            <p>
                                <label for="cardnumber">Precio Costo</label>
                                <input id="precio_costo2" name="precio_costo" type="number" value="<?php echo $rowe[7] ?>" />
                            </p>
                            <p>
                                <label for="cardnumber">Precio Venta</label>
                                <input id="precio_venta2" name="precio_venta" type="number" AUTOCOMPLETE=OFF value="<?php echo $rowe[7] ?>"/>
                            </p>
                            <p>
                                <label for="cardnumber">Margen</label>
                                <input id="margen2" name="margen" type="number" AUTOCOMPLETE=OFF value="<?php echo $rowe[9] ?>"/>
                            </p>
                            <p>
                                <label for="proveedor">Proveedor</label>
<select name='proveedor'>
<optgroup label='Proveedores Disponibles'>";
	<?php
$qry=mysql_query("select prv_rut,prv_nombre from prv_proveedor");
while($row=mysql_fetch_row($qry)){
echo "<option value='$row[0]'";if($row[0]==$rowe[10]){echo "selected='selected'";}echo">$row[1]</option>";

}
?>
</select>
                            </p> 
                            <p>
                                <label for="subcategoria">Unidad Compra</label>
<select name='unidad_compra'>
<optgroup label='Unidades Disponibles'>";
	<?php
$qry=mysql_query("select env_codigo,env_sigla from env_envase");
while($row=mysql_fetch_row($qry)){
echo "<option value='$row[0]'";if($row[0]==$rowe[11]){echo "selected='selected'";}echo">$row[1]</option>";

}
?>
</select>
                            </p>
                            <p>
                                <label for="subcategoria">Unidad Venta</label>
<select name='unidad_venta'>
<optgroup label='Unidades Disponibles'>";
	<?php
	mysql_query("delete from for_formulas where for_formula='temp'");
$qry=mysql_query("select env_codigo,env_sigla from env_envase");
while($row=mysql_fetch_row($qry)){
echo "<option value='$row[0]'";if($row[0]==$rowe[12]){echo "selected='selected'";}echo">$row[1]</option>";

}
?>
</select>
                            </p>  
                            <p>
                                <label for="cardnumber">Fecha Ingreso</label>
                                <input id="fecha_ingreso" name="fecha_ingreso" value="<?php echo $rowe[13] ?>" readonly="readonly"/>
                            </p>
                        </fieldset>
                        <fieldset class="step">
                            <legend>Nuevo Producto</legend>
                            <p>
                                <label for="name">Stock Minimo Bodega</label>
                                <input id="stock_minimo_bodega" name="stock_minimo_bodega" type="number" value="<?php echo $rowe[14] ?>"/>
                            </p>
                            <p>
                                <label for="name">Stock Critico Bodega</label>
                                <input id="stock_critico_bodega" name="stock_critico_bodega" type="number" value="<?php echo $rowe[16] ?>""/>
                            </p>  
                            <p>
                                <label for="name">Stock Maximo Bodega</label>
                                <input id="stock_maximo_bodega" name="stock_maximo_bodega" type="number"value="<?php echo $rowe[15] ?>"/>
                            </p>     
                            <p>
                                <label for="name">Stock Minimo Sala Venta</label>
                                <input id="stock_minimo_sala_venta" name="stock_minimo_sala_venta" type="number" value="<?php echo $rowe[17] ?>"/>
                            </p>   
                            <p>
                                <label for="name">Stock Maximo Sala Venta</label>
                                <input id="stock_maximo_sala_venta" name="stock_maximo_sala_venta" type="number" value="<?php echo $rowe[18] ?>"/>
                            </p>  
                            <p>
                                <label for="tipo">Estado</label>
                                <select id="estado" name="estado">
                                	<option value="A" <?php  if($tipo=="A"){echo "selected='selected'";} ?>>Activo</option>
                                	<option value="I" <?php  if($tipo=="I"){echo "selected='selected'";} ?>>Inactivo</option>
                                </select>
                            </p> 
                            <p>Ultima Edición: <?php echo $rowe[20]?>, por el usuario: 
                            	<?php echo $rowe[21] ?></p>
                                                                      
                        </fieldset>
                        <fieldset class="step">
                            <legend>Nuevo Producto Formula</legend>
                              <p><label>Formulanle</label>
                              	<input name="check_formula2" id="check_formula2" type="checkbox" value="S" <?php  if($rowe[24]=="S"){echo "checked='checked'";} ?>/>
  							</p>     

                        
 <p>
<label for="segundo_producto">Ingrediente</label>
<select name='valor_uno2' id="valor_uno2" class="formula">
<optgroup label='Productos Disponibles'>";
	<?php
$qry=mysql_query("select pro_codigo,pro_descripcion_corta from pro_productos");
while($row=mysql_fetch_row($qry)){
echo "<option value='$row[0]'>$row[1]</option>";
}
?>
</select> 
</p>
                        <!--<tr>
                            <td>Descripcion Ingrediente</td>
                            <td><input name="valor_dos" type="text" id="valor_dos" size="40" class="required" /></td>
                        </tr> -->
                        
                       <p>     <label for="porcentaje">Porcentaje %</label>
                            <input name="valor_dos2" type="text" id="valor_dos2" class="formula" size="30" placeholder="20"/>
                     </p>
                     <p>
                          <input name="agregar2" type="button" id="agregar2" value="Agregar" />
                     </p>
              <div style="height:160px;width:600px; overflow:scroll;">
            <table id="grilla2" class="lista">
              <thead>
                    <tr>
                        <th>Codigo Ingrediente</th>
                        <th>Descripcion</th>
                        <th>Codigo Producto</th>
                        <th>Porcentaje Ingrediente</th>
                    </tr>
                </thead>
                <tbody>
                	
                			<?php
		//for_formula->prod final
	//for_codigo->ingrediente
	$consulta="SELECT for_formula,for_codigo,pro_descripcion_corta,for_porcen FROM for_formulas INNER JOIN pro_productos 
ON pro_productos.pro_codigo=for_formulas.for_codigo
WHERE for_formulas.for_formula='".$id."'";
$qry=mysql_query($consulta);
//echo $consulta;
while($row=mysql_fetch_row($qry)){
echo "					<tr>
                		<td>$row[1]</td>
                		<td>$row[2]</td>
                		<td>$row[0]</td>
                		<td>$row[3]</td>
                		<td><a class='elimina2' id='eliminag2' name='eliminag2'><img src='images/delete.png'></a></td>
                		</tr>";
}
echo "<input value='$id' id='id_producto' name='id_producto'  style='display:none'>
<input value='$rowe[22]' id='pro_oferta' name='pro_oferta'  style='display:none'>
";
?>
                	
                		
                		
                	
                </tbody>
            </table>
        </div>    
              </fieldset>
              
<fieldset class="step">
                            <legend>Nuevo Producto Oferta</legend>
                            
  							 <p><label>Oferta</label>
  							 	<input name="check_oferta2" id="check_oferta2" type="checkbox" value="S" <?php  if($rowe[22]=="S"){echo "checked='checked'";} ?>/>
  							</p> 
	<?php
$qry=mysql_query("select * from ofe_oferta where pro_codigo='$id'");
$rowo=array();
$nombre_oferta="";
	$fecha_inicio="";
	$fecha_fin="";
	$cantidad="";
	$local="";
	$descuento="";
	$valor_ultimo="";
	$segundo_producto="";
while($rowo=mysql_fetch_row($qry)){
	$nombre_oferta=$rowo[1];
	$fecha_inicio=$rowo[3];
	$fecha_fin=$rowo[4];
	$cantidad=$rowo[5];
	$local=$rowo[6];
	$descuento=$rowo[7];
	$valor_ultimo=$rowo[8];
	$segundo_producto=$rowo[9];	
}
?>
<div id="cale2">
   <table>
      <tr>
        <td style="width: 10em">
          <div id="cont2"></div>
          
        </td>
      </tr>
    </table>
</div>
		                            <p>
                                <label for="country">Mombre de Oferta</label>
                                <input type='text' class="oferta" name='nombre_oferta' id="nombre_oferta" value="<?php echo $nombre_oferta; ?>"/>

                            </p>

                            <p>
                                <label for="country">Fecha Inicio</label>
                                <input type='text' class="oferta" name='fecha_inicio2' id="fecha_inicio"  value="<?php echo $fecha_inicio; ?>" readonly />

                            </p>
                            <p>
                                <label for="country">Fecha Fin</label>
                                <input type='text' class="oferta" name='fecha_fin2' id="fecha_fin"  value="<?php echo $fecha_fin; ?>" readonly/>
                            </p>
                           <p>
                                <label for="cantidad">Cantidad</label>
                                <input type='number' class="oferta" name='cantidad_oferta' id="cantidad_oferta" value="<?php echo $cantidad; ?>"/>
                            </p>
                           <p>
                                <label for="cantidad">Targeta Local</label>
                                  <select id="targeta_local" name="targeta_local" class="oferta" id="targeta_local">
                                	<option value="N" <?php  if($local=="N"){echo "selected='selected'";} ?>>No</option>
                                	<option value="S" <?php  if($local=="S"){echo "selected='selected'";} ?>>Si</option>
                                </select>
                            </p> 
                                                     
                          
                        </fieldset>
						<fieldset class="step">
                            <legend>Nuevo Producto Oferta</legend>
                            
 <p>
                                <label for="descuento">Descuento %</label>
                                <input type='number' class="oferta" name='descuento' id="descuento" value="<?php echo $descuento; ?>" "/>
                            </p>                           
                           <p>
                                <label for="valor_ultimo">Valor Ultimo Producto</label>
                                <input type='number' class="oferta" name='valor_ultimo' id="valor_ultimo" value="<?php echo $valor_ultimo; ?>"  "/>
                           </p>
<p>
<label for="segundo_producto">Segundo Producto</label>
<select name='segundo_producto' class="oferta" id="segundo_producto">
<optgroup label='Productos Disponibles'>";
	<?php
$qry=mysql_query("select pro_codigo,pro_descripcion_corta from pro_productos");
while($row=mysql_fetch_row($qry)){
	echo "<option value='0'>Ninguno</option>";
echo "<option value='$row[0]'";if($row[0]==$segundo_producto){echo " selected='selected'";}echo">$row[1]</option>";
}
?>
</select> 
</p>



<p>
	 
                            <p class="submit">
                                <button id="registerButton2" name="do" value="Editar Producto"type="submit">Grabar</button>
                            </p>
	</p>
                        </fieldset>
                    </form>
                </div>
                <div id="navigation2" style="display:none;">
                    <ul>
                       <li class="selected">
                            <a href="#">Calsificacion</a>
                        </li>
                        <li>
                            <a href="#">Datos</a>
                        </li>
                        <li>
                            <a href="#">Stock</a>
                        </li>
                        <li>
                            <a href="#">Formula</a>
                        </li>
                        <li>
                            <a href="#">Oferta parte 1</a>
                        </li>
						<li>
                            <a href="#">Oferta parte 2</a>
                        </li>
                    </ul>
                </div>
            </div>
            


</div>

</div>
</div>

<!-- end pop up -->
						<?php
include "includes/inicia_calendario_edit.php";
					}//while cate
					break;
case "usuarios" :
					$c = "select * from s_usr_usuarios where susr_usuario='$id'";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
						echo "
<!-- pop up -->
<div id='login-box-usr-edit' class='login-popup'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<form method='post' class='signin' action='includes/funciones.php'>

<center>
<span><h2>Editar Usuario</h2></span>
</center>
<fieldset class='textbox'>
<center>
<table>



<tr>
<td><span>Rut</span></td>
<td><input type='rut' name='rut' id='rut' required='required' value='$row[1]'><input type='dv' id='dv' name='dv' value='$row[2]'></td>
</tr>
<tr>
<tr>
<td><span>Nombre</span></td>
<td><input type='text' name='nombre' required='required' value='$row[3]'> </td>
</tr>
<tr>
<tr>
<td><span>Grupo</span></td>
<td>
<select name='grupo'>
<optgroup label='Grupos Disponibles'>";
$qry=mysql_query("select * from s_grp_grupos");
while($rowg=mysql_fetch_row($qry)){
echo "<option value='$rowg[0]'";if($rowg[0]==$row[5]){echo "selected='selected'";}echo">$rowg[1]</option>";
}
echo"
</select>
</td>
</tr>
<tr>
<tr>
<td><span>Usuario</span></td>
<td><input type='text' name='usuario' required='requiered' value='$row[4]'> </td>
</tr>
<tr>
<tr>
<td><span>Clave</span></td>
<td><input type='password' name='clave' requiered='requiered' value='$row[6]'> </td>
</tr>

<input name='id' value='$id' style='display: none;'>
</table>
</center>
<button type='submit' class='submit button' id='do' name='do' value='Editar Usuario'>
Grabar</button>
</fieldset>
</form>
</div>
</div>
</div>

<!-- end pop up -->
";
					}//while
					break;
case "grupos":
					$c = "select * from s_grp_grupos where sgrp_grupo='$id'";
					$qry = mysql_query($c);
					while ($row = mysql_fetch_row($qry)) {
?>
				
<!-- pop up -->
<div id='login-box-grp-edit' class='login-popup-asi'>
<a href='#' class='close'><img src='images/close_pop.png' class='btn_close' title='Close Window' alt='Close' /></a>
<div id="wrapper-asi">
	<div id="steps">
<form method='post' class='signin' name='form_categoria'  action='includes/funciones.php'>

       <fieldset class="step">
<legend>Editar Grupo</legend>
<p>
<label for="codigo_barra">Grupo</label>
<input id="grupo" name="grupo" type="text" required="required" value='<?php echo $row[0] ?>' />
</p>

<p>
<label for="descripcion">Descripcion</label>
<input id="descripcion" name="descripcion" type="text" required="required" value='<?php echo $row[1] ?>' />
</p>                 
                            
<p>
<label for="descripcion">Areas</label>
<select name='areas2' id='areas2'>
<optgroup label='Opciones Disponibles'>
<?php
$qry=mysql_query("SELECT * FROM s_are_areas");
while($rowa=mysql_fetch_row($qry)){
echo "<option value='$rowa[0]'>$rowa[1]</option>";
}
?>
</select>	
</p>                 
       
<p id='actividad_div2'>


</p>                 
       
<p>
<input name="agregarg2" type="button" id="agregarg2" value="Agregar" />
</p>
    <div style="height:160px;width:600px; overflow:scroll;">        
<table id="grillag2" class="lista">
<thead>
<tr>

<th>Codigo Act.</th>
<th>Codigo Area</th>
<th>Actividad</th>
<th>Area</th>
</tr>
</thead>
<tbody>
<?php
echo"<input name='id' value='$id' style='dislay:none'>";
$consulta="SELECT
    saxg_actividad
    , sare_area
    , s_act_actividades.sact_descripcion
    , sare_area
FROM
    s_act_actividades
    INNER JOIN s_are_areas 
        ON (s_act_actividades.sact_area = s_are_areas.sare_area)
    INNER JOIN s_axg_actgrps 
        ON (s_axg_actgrps.saxg_actividad = s_act_actividades.sact_actividad)
        WHERE s_axg_actgrps.saxg_grupo='$id'";
 $qry=mysql_query($consulta);
//echo $consulta;
while($rowa=mysql_fetch_row($qry)){
echo "					<tr>
                		<td>$rowa[0]</td>
                		<td>$rowa[1]</td>
                		<td>$rowa[2]</td>
                		<td>$rowa[3]</td>
                		<td><a class='elimina2' id='eliminag2' name='eliminag2'><img src='images/delete.png'></a></td>
                		</tr>";
}
?>
</tbody>
</table>
</div> 
<p class="submit">
                                <button type="submit" class="submit" name="do" value="Editar Grupo">Grabar</button>
                              
                            </p>
</fieldset>
                           
</form>
</div>
</div>
</div>

<!-- end pop up -->
<?php }
break;
				
			}//switch
		}
?>